package DSN;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import javax.sql.DataSource;

public class DBUtil {
    public DataSource Hikar_DataSource_NMGGS() throws Exception{
        HikariConfig config=new HikariConfig();
        try {
            config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
            config.setJdbcUrl("jdbc:oracle:thin:@//10.15.0.11:1521/orcl");
            config.setUsername("nmggs");
            config.setPoolName("nmggs");
            config.setPassword("sysadmin");
            config.addDataSourceProperty("v$session.osuser","DL");
            config.addDataSourceProperty("v$session.machine","10.15.0.36");
            config.addDataSourceProperty("v$session.program","DIV_SEC");
            config.setMaximumPoolSize(10);
            config.setMinimumIdle(2);
            config.setConnectionTestQuery("select 1 from dual");
            config.setAutoCommit(true);
        }
        catch (Exception e){
            System.out.println("连接池错误："+e.toString());
        }
        DataSource ds=new HikariDataSource(config);
        return ds;
    }

    public DataSource Hikar_DataSource_JTJT() throws Exception{
        HikariConfig config=new HikariConfig();
        try {
            config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
            config.setJdbcUrl("jdbc:oracle:thin:@//10.15.0.12:1521/orcl");
            config.setUsername("nmgjtjt");
            config.setPoolName("nmgjtjt");
            config.setPassword("sysadmin");
            config.setMaximumPoolSize(10);
            config.setMinimumIdle(2);
            config.setIdleTimeout(600000);
            config.setConnectionTestQuery("select 1 from dual");
            config.setAutoCommit(true);
        }
        catch (Exception e){
            System.out.println("连接池错误："+e.toString());
        }
        DataSource ds=new HikariDataSource(config);
        return ds;
    }

    public DataSource Hikar_DataSource_MPAY() throws Exception{
        HikariConfig config=new HikariConfig();
        try {
            config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
            config.setJdbcUrl("jdbc:oracle:thin:@//10.15.100.5:1521/torcl");
            config.setUsername("nmgmpayadmin");
            config.setPoolName("nmggs");
            config.setPassword("nmgh90[]");
            config.setMaximumPoolSize(10);
            config.setMinimumIdle(2);
            config.setIdleTimeout(600000);
            config.setConnectionTestQuery("select 1 from dual");
            config.setAutoCommit(true);
        }
        catch (Exception e){
            System.out.println("连接池错误："+e.toString());
        }
        DataSource ds=new HikariDataSource(config);
        return ds;
    }

    public DataSource Hikar_DataSource_GT() throws Exception{
        HikariConfig config=new HikariConfig();
        try {
            config.setDriverClassName("oracle.jdbc.driver.OracleDriver");
            config.setJdbcUrl("jdbc:oracle:thin:@//10.15.100.5:1521/torcl");
            config.setUsername("nmggtadmin");
            config.setPoolName("nmggs");
            config.setPassword("nmgh90[]");
            config.addDataSourceProperty("v$session.osuser","DL");
            config.addDataSourceProperty("v$session.machine","10.15.0.36");
            config.addDataSourceProperty("v$session.program","DIV_SEC");
            config.setMaximumPoolSize(10);
            config.setMinimumIdle(2);
            config.setConnectionTestQuery("select 1 from dual");
            config.setAutoCommit(true);
        }
        catch (Exception e){
            System.out.println("连接池错误："+e.toString());
        }
        DataSource ds=new HikariDataSource(config);
        return ds;
    }
    public DataSource Hikar_DataSource_DM() throws Exception {//这个是今天改的
        HikariConfig config = new HikariConfig();
        try {

            config.setDriverClassName("dm.jdbc.driver.DmDriver");
            config.setJdbcUrl("jdbc:dm://10.115.255.4:5236/NMGGJT");
            config.setUsername("NMGGJT");
            config.setPassword("1234567890");
            config.setPoolName("GTDM");
            config.setMaximumPoolSize(4);
            config.setMinimumIdle(2);
            config.setConnectionTestQuery("select 1 from dual");
            config.setAutoCommit(true);
            DataSource ds = new HikariDataSource(config);
            return ds;
        }
        catch (Exception e){
            LogClass.error(e.getMessage());
        }
        finally {
            return new HikariDataSource(config);
        }


    }

    public DataSource Hikar_DataSource_216() throws Exception{
        HikariConfig config=new HikariConfig();
        try {
            config.setDriverClassName("oracle.jdbc.OracleDriver");
            config.setJdbcUrl("jdbc:oracle:thin:@//10.15.100.216:1521/torclhis");
            config.setUsername("transfer");
            config.setPoolName("216");
            config.setPassword("trans2020");
            config.setMaximumPoolSize(3);
            config.setMinimumIdle(2);
            config.setConnectionTestQuery("select 1 from dual");
            config.setAutoCommit(true);

        }
        catch (Exception e){
            System.out.println("连接池错误："+e.toString());
        }
        DataSource ds=new HikariDataSource(config);
        return ds;
    }

}
